import React from "react";
import { withRouter} from "react-router-dom"
import CommService from "@/data/index"
function BrandItem(props){

    const {dataId,brand_logo,brand_name,history}=props;
    function queryCarSeries(id){
        if(!sessionStorage.series){
            CommService['serviceSeries']({brandid:id}).then(res=>{
                sessionStorage.series =JSON.stringify(res)
                history.push(`/series?id=${id}`)
            })
        }else{
            history.push(`/series?id=${id}`)
        }
    }
    return (
        <li className="flex" key={dataId} onClick={()=>queryCarSeries(dataId)}>
            <div className="pic">
                <img src={brand_logo} />    
            </div>   
            <div className="flex-1 name">{brand_name}</div>
        </li>
    )
}
export default withRouter(BrandItem)